<?php
/**
 * Created by PhpStorm.
 * User: zjw
 * Date: 2018/3/8
 * Time: 下午4:00
 */
use common\models\CouponCategory;
use yii\grid\GridView;
use yii\helpers\Html;

?>

    <p>
        <?= Html::a(Yii::t('app', '设置提前通知时间'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'customer_id',
            'message_title',
            'message_body',
            'page_link_url',
            'product_id',
            'page_title',
            [
                'attribute' => 'created_at',
                'value' => function ($model) {
                    return date("Y-m-d H:i:s", $model->created_at);
                }
            ],
            [
                'attribute' => 'updated_at',
                'value' => function ($model) {
                    return date("Y-m-d H:i:s", $model->updated_at);
                }
            ],
            [
                'attribute' => 'notice_at',
                'value' => function ($model) {
                    return date("Y-m-d H:i:s", $model->notice_at);
                }
            ],
            [
                'attribute' => 'status',
                'value' => function ($model) {
                    return \common\models\Subscription::getStatusList()[$model->status];
                }
            ],

            ['class' => 'yii\grid\ActionColumn',
                'template' => ' {delete} {url} {exec}',
                'buttons' => [
                    'exec' => function ($url, $model, $key) {
                        return Html::a('执行', ['execute', 'id' => $key], ['class'=>'btn btn-sm btn-primary']);
                    }
                ],
            ],
        ],
    ]); ?>
</div>